package com.tencent.stat.event;

import android.content.Context;
import com.tencent.stat.StatConfig;
import com.tencent.stat.StatSpecifyReportedInfo;
import com.tencent.stat.common.Util;
import com.tencent.stat.common.a;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.json.JSONObject;

public class d extends e
{
  private String a;
  private int m;
  private Thread n = null;

  public d(Context paramContext, int paramInt1, int paramInt2, Throwable paramThrowable, StatSpecifyReportedInfo paramStatSpecifyReportedInfo)
  {
    super(paramContext, paramInt1, paramStatSpecifyReportedInfo);
    a(paramInt2, paramThrowable);
  }

  public d(Context paramContext, int paramInt1, int paramInt2, Throwable paramThrowable, Thread paramThread, StatSpecifyReportedInfo paramStatSpecifyReportedInfo)
  {
    super(paramContext, paramInt1, paramStatSpecifyReportedInfo);
    a(paramInt2, paramThrowable);
    this.n = paramThread;
  }

  public d(Context paramContext, int paramInt1, String paramString, int paramInt2, int paramInt3, Thread paramThread, StatSpecifyReportedInfo paramStatSpecifyReportedInfo)
  {
    super(paramContext, paramInt1, paramStatSpecifyReportedInfo);
    if (paramString != null)
    {
      paramInt1 = paramInt3;
      if (paramInt3 <= 0)
        paramInt1 = StatConfig.getMaxReportEventLength();
      if (paramString.length() > paramInt1)
        break label55;
    }
    for (this.a = paramString; ; this.a = paramString.substring(0, paramInt1))
    {
      this.n = paramThread;
      this.m = paramInt2;
      label55: return;
    }
  }

  private void a(int paramInt, Throwable paramThrowable)
  {
    if (paramThrowable == null)
      return;
    StringWriter localStringWriter = new StringWriter();
    PrintWriter localPrintWriter = new PrintWriter(localStringWriter);
    paramThrowable.printStackTrace(localPrintWriter);
    this.a = localStringWriter.toString();
    this.m = paramInt;
    localPrintWriter.close();
  }

  public EventType a()
  {
    return EventType.ERROR;
  }

  public void a(long paramLong)
  {
    this.c = paramLong;
  }

  public boolean a(JSONObject paramJSONObject)
  {
    Util.jsonPut(paramJSONObject, "er", this.a);
    paramJSONObject.put("ea", this.m);
    if ((this.m == 2) || (this.m == 3))
      new a(this.l).a(paramJSONObject, this.n);
    return true;
  }
}